package stack.mine;

import java.util.Stack;

/**
 * @BelongsProject: leetcode
 * @BelongsPackage: stack.mine
 * @Author: Administrator
 * @CreateTime: 2018-12-09 16:42
 * @Description: ${Description}
 */
public class StackToQueue {
    private Stack<Integer> stack=new Stack<>();

    /** Initialize your data structure here. */
    public StackToQueue() {

    }

    public void push(int x) {
        int  stackSize= stack.size();
        Stack<Integer> tempStack=new Stack<>();
        for (int i = 0; i <stackSize ; i++) {
            tempStack.push(stack.pop());
        }
        tempStack.push(x);
        int  tempStackSzie=tempStack.size();
        for (int i = 0; i <tempStackSzie ; i++) {
            stack.push(tempStack.pop());
        }
    }

    /** Removes the element from in front of queue and returns that element. */
    public int pop() {
        return  stack.pop();
    }

    /** Get the front element. */
    public int peek() {
        return  stack.peek();
    }

    /** Returns whether the queue is empty. */
    public boolean empty() {
        return stack.empty();
    }

}
